package com.fau.fm.action.index;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;

import com.fau.fm.action.PublicAction;
import com.fau.fm.entity.MedicalAdmin;
import com.fau.fm.entity.MedicalLogisticsStatistics;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ModelDriven;

/**
 * @desc 物流公司业务统计Action
 * @author liy
 * @datetime 2014年11月15日,下午3:19:09
 */
@Controller
@Scope("prototype")
@ParentPackage("default")
@Namespace("/")
public class FinancialStatisticsAction extends PublicAction implements ModelDriven<MedicalLogisticsStatistics>{

	private static final long serialVersionUID = 2976861610603052109L;

	private MedicalLogisticsStatistics bean = new MedicalLogisticsStatistics();
	
	/**
	 * @desc 进入物流公司业务统计页面
	 * @return String
	 * @author liy
	 * @datetime 2014年11月15日,下午4:33:29
	 */
	@Action(value = "logistics_sta", results = {@Result(location = "logistics_sta.jsp")})
	public String logisticsSta(){
		return SUCCESS;
	}
	
	/**
	 * @desc 物流公司业务统计数据展示
	 * @return
	 * @author dangjh
	 * @datetime 2014年11月25日,下午8:57:08
	 */
	@Action(value = "logistics_sta_view")
	public String logisticsStaView() {
		HttpServletResponse response = ServletActionContext.getResponse();
		MedicalAdmin admin = (MedicalAdmin) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		bean.setHospitalId(admin.getEnterpriseId());
		map = ActionContext.getContext().getParameters();
		pageBean = this.baseAllService.getStatisticsService().findAllLogistics(map, bean);
		map.clear();
		map.put("total", pageBean.getTotalRow());
		map.put("data", pageBean.getResult());
		formatJSON(response, map);
		return null;
	}
	
	@Override
	public MedicalLogisticsStatistics getModel() {
		return bean;
	}
	
}
